//完成与权限表相关的操作
const db = require('./db.js');

//获得所有权限
module.exports.getAllPerm = async () =>{
	return await db.q('SELECT * FROM sp_permission_api as api Left JOIN sp_permission as main ON main.ps_id = api.ps_id WHERE main.ps_id is not null',null)
}
// 获得总条数
module.exports.getPermCount = async () =>{
	return await db.q('select count(*) cou from sp_permission',null);
}
//按页获得权限数据
module.exports.getPermByPage = async (pageInfo) =>{
	let sql = 'SELECT * FROM sp_permission sp  INNER JOIN sp_permission_api spa ON sp.ps_id = spa.ps_id LIMIT ?,?';
	return await db.q(sql,pageInfo);
}
